<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example of a simple class diagram using the jsUML2 library</title>

      <link type="text/css" rel="stylesheet" href="<%= request.getContextPath()%>/css/udstyle.css" media="screen"/>
      
    <script type="text/javascript" src="<%= request.getContextPath()%>/js/udcore.js"></script>
    <script type="text/javascript" src="<%= request.getContextPath()%>/js/udmodules.js"></script>


    <script type="text/javascript">
    window.onload = function(){

        var classDiagram = new UMLClassDiagram({id: 'classDiagram', width: 580, height: 500 });

        // Adding classes...
        var flightPlanClass = new UMLClass({ x:100, y:50 });
        var flightPointClass = new UMLClass({ x:30, y:300 });
        var flightLineClass = new UMLClass({ x:150, y:400 });
        var airportClass = new UMLClass({ x:400, y:400 });

        classDiagram.addElement(flightPlanClass);
        classDiagram.addElement(flightPointClass);
        classDiagram.addElement(flightLineClass);
        classDiagram.addElement(airportClass);
    


        //Defining flightPlanClass
        flightPlanClass.setName("flightPlan");
        flightPlanClass.addAttribute( 'airpoint' );
        flightPlanClass.addAttribute( 'flightLine' );
        flightPlanClass.addOperation( 'getAirport()' );
        flightPlanClass.addOperation( 'getFightLine()' );
        
        //Defining flightPointClass
        flightPointClass.setName("flightPoint");
        flightPointClass.addAttribute( 'height' );
        flightPointClass.addAttribute( 'latitude' );
        flightPointClass.addAttribute( 'longitude' );
        flightPointClass.addAttribute( 'order' );
        flightPointClass.addOperation( 'getAttr()' );

        //Defining flightLineClass
        flightLineClass.setName("flightLine");
        flightLineClass.addAttribute( 'currentPoint' );
        flightLineClass.addOperation( 'getCurrentPoint()' );

        //Defining airportClass
        airportClass.setName("airpoint");
        airportClass.addAttribute( 'name' );
        airportClass.addOperation( 'getName()' );
          
        // Adding generalizations...
        var composition2 = new UMLComposition({ b:airportClass, a:flightPlanClass });
        var composition3 = new UMLComposition({ b:flightPointClass, a:flightPlanClass });
        var composition4 = new UMLComposition({ b:flightLineClass, a:flightPlanClass });
        classDiagram.addElement(composition2);
        classDiagram.addElement(composition3);
        classDiagram.addElement(composition4);
        
        
        var generalization1 = new UMLGeneralization({ b:flightPointClass, a:airportClass });
        classDiagram.addElement(generalization1); 
        
		var composition1 = new UMLComposition({ b:flightPointClass, a:flightLineClass });
		classDiagram.addElement(composition1);
        
    	// Adding other relations
        /*var directedAssociation = new UMLAssociation({a:flightLineClass , b: sailorClass});

        directedAssociation.setRoleB( "Work on");
        directedAssociation.setComponentMultiplicityB('*');
        directedAssociation.setDirection('a');

        classDiagram.addElement(directedAssociation);
        */
        //Draw the diagram
        classDiagram.draw();

        //Interaction is possible (editable)
        classDiagram.interaction(false);
    }

    </script>
    </head>

    <body>
<div id="classDiagram"></div>
    </body>
</html>
